﻿using GoldIngot.API.Application.Commands.SigningWorkCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using IMES.Common.Dtos;
using IMES.Common.Domain.GoldIngotModel;
using GoldIngot.API.Application.Commands.CompletionOrderCommand;

namespace GoldIngot.API.Controllers
{
    /// <summary>
    /// 生产管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GoldIngotController : ControllerBase
    {
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public GoldIngotController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 报工显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>

        [HttpPost("SigningSelect")]
        public async Task<Result> Handle(SigningWorkSelectCommand request)
        {
            return await _mediator.Send(request);
        }


        /// <summary>
        /// 报工添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("SigningCreate")]
        public async Task<Result> Handle(SigningWorkCreateCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 报工反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("SigningFill")]
        public async Task<ResultT<SigningWork>> Handle(SigningWorkFillCommand request)
        {
            return await _mediator.Send(request);
        }


        /// <summary>
        /// 报工修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>

        [HttpPost("SigningUpdate")]
        public async Task<Result> Handle(SigningWorkUpdateCommand request)
        {
            return await _mediator.Send(request);
        }


        /// <summary>
        /// 报工删除（逻辑删除）
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete("SigningDelete")]
        public async Task<Result> Handle(SigningWorkDeleteCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 完工单列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("CompletionOrderSelect")]
        public async Task<Result> Handle(CompletionOrderSelectCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 完工单审核
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("CompletionOrderUpdate")]
        public async Task<Result> Handle(CompletionOrderUpdateCommand request)
        {
            return await _mediator.Send(request);
        }
    }
}
